/**
 * 
 */
package com.bagtrack.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bagtrack.model.Job;
import com.bagtrack.model.StartJobRequest;
import com.bagtrack.service.IJobService;


/**
 * Controller Class for handling requests for the JobService.
 * @author Brian Boyle
 * Nov 19, 2011
 */
@Controller
public class JobController {

    @Autowired
    private IJobService jobService;


    /**
     * @param jobService the jobService to set
     */
    public void setJobService(IJobService jobService) {
        this.jobService = jobService;
    }

    @RequestMapping(value = "/start", method = RequestMethod.POST, headers = "Accept=application/json")
    public @ResponseBody
    int startJob(@RequestBody StartJobRequest startJobRequest) {
        Job job = jobService.startJob(startJobRequest);
        return job.getId().intValue();
    }
}
